#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,c[100],t[100],w[100],m,sj[3000],sy[3000],cnt,dp[10010],flg[30],ans;
void dfs(int u){
	if(u>cnt){
		int zh=0,sum=0;
		for(int i=1;i<=cnt;i++)
			if(flg[i]) zh+=sj[i],sum+=sy[i];
		if(zh<=m) ans=max(ans,sum);
		return;
	}
	flg[u]=1;
	dfs(u+1);
	flg[u]=0;
	dfs(u+1);
}
signed main(){
	freopen("book.in","r",stdin);
	freopen("book.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld",&c[i]);
	for(int i=1;i<=n;i++)
		scanf("%lld",&t[i]);
	for(int i=1;i<=n;i++){
		scanf("%lld",&w[i]);
		for(int j=0;j<=30;j++)
			if(c[i]>=(1<<j)){
				sj[++cnt]=(1<<j)*t[i],sy[cnt]=(1<<j)*w[i];
				c[i]-=1<<j;
			}
		if(c[i]) sj[++cnt]=c[i]*t[i],sy[cnt]=c[i]*w[i];
	}
	scanf("%lld",&m);
	if(m<=10000){
		memset(dp,128,sizeof(dp));
		dp[0]=0;
		for(int i=1;i<=cnt;i++)
			for(int j=m;j>=sj[i];j--)
				dp[j]=max(dp[j],dp[j-sj[i]]+sy[i]);
		printf("%lld",dp[m]);
	}else{
		dfs(1);
		printf("%lld",ans);
	}
	return 0;
}
